<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/1999/REC-html401-19991224/strict.dtd">
<html><head>
<title>reference_counting</title>
</head><body>
<p>[<a href="mxdoc.htm">mainpage</a>]
[<a href="tags.htm">tags</a>]<br>
<h1>tag: reference_counting</h1><ul><li>
<a name="MX_ATOM"><code>MX_ATOM</code></a>
<p>
<p><b>Base class for reference counting and delete locking</b><p>

MX_ATOM is an object intended to be used as a base class to
implement reference counting and delete locking in the derived class.
<p>
Properly constructed MX_ATOM objects are bit-copy-correct which means that
a binary copy retains proper functioning.  The copied object should not be
used after the binary copy.
<p>
Because MX_ATOM is bit-copy-correct it can safely be placed in a MX_VECTOR
or the memory realloc'd.  
(<a href="../include/deds/atom.h">../include/deds/atom.h</a>)<br>(library <a href="deds.htm">deds</a> : module <a href="deds_atom.htm">atom</a>)
<p></li>
<li>
<a name=" define mx_atom(a,d,s)"><code># define mx_atom(a,d,s)</code></a>
<p>
<p><b>Construct an MX_ATOM</b><p>
This macro constructs a MX_ATOM which is a base object for reference counting.  
(<a href="../include/deds/atom.h">../include/deds/atom.h</a>)<br>(library <a href="deds.htm">deds</a> : module <a href="deds_atom.htm">atom</a>)
<p></li>
<li>
<a name=" define mx_delete(a)"><code># define mx_delete(a)</code></a>
<p>
<p><b>Destroy an MX_ATOM</b><p>
This macro causes an object to be marked for destruction.  If no locks (MX_LOCK)
or references (MX_REF) exist for this object then the object is destroyed and
if appropitae the memory is released.  
(<a href="../include/deds/atom.h">../include/deds/atom.h</a>)<br>(library <a href="deds.htm">deds</a> : module <a href="deds_atom.htm">atom</a>)
<p></li>
<li>
<a name=" define mx_locked(a)"><code># define mx_locked(a)</code></a>
<p>
<p><b>Find out if an object is locked or not  </b><p>
(<a href="../include/deds/atom.h">../include/deds/atom.h</a>)<br>(library <a href="deds.htm">deds</a> : module <a href="deds_atom.htm">atom</a>)
<p></li>
<li>
<a name="MX_LOCK"><code>MX_LOCK</code></a>
<p>
<p><b>Stop MX_ATOMs from getting deleted</b><p>
This object implements a delete lock for an MX_ATOM.  While a valid 
MX_LOCK exists for an MX_ATOM object (or one derived from it) the
object is guaranteed not be deleted.  An object can have multiple locks
placed on it. <p>
MX_LOCK is NOT bit-copy-correct so it cannot safely be placed in a MX_VECTOR
or in memory that gets realloc'd.  
(<a href="../include/deds/atom.h">../include/deds/atom.h</a>)<br>(library <a href="deds.htm">deds</a> : module <a href="deds_atom.htm">atom</a>)
<p></li>
<li>
<a name=" define mx_lock(l,a)"><code># define mx_lock(l,a)</code></a>
<p>
<p><b>Construct a MX_LOCK</b><p>
This macro creates a lock for an object derived from MX_ATOM.  The locked 
MX_ATOM is guaranteed not to be deleted while a valid lock exists.  
(<a href="../include/deds/atom.h">../include/deds/atom.h</a>)<br>(library <a href="deds.htm">deds</a> : module <a href="deds_atom.htm">atom</a>)
<p></li>
<li>
<a name="unsigned mx_unlock(MX_LOCK* lock)"><code>unsigned mx_unlock(MX_LOCK* lock)</code></a>
<p>
<p><b>Destruct a MX_LOCK</b><p>
This function destroys a MX_LOCK and removes it from it's associated
MX_ATOM object.  If the object has been flagged for deletion (with the
mx_delete() macro) then removal of the last lock caused the MX_ATOM
destructor to be called and (if necessary) memory returned to the operating
system.
<p>
If the release of the lock triggered calling of the object destructor then
the function returns non-zero.  If this occurs then it is not safe to access
the object anymore.  If this function returns false then either:<ol>
<li>Other locks exist for the object.</li>
<li>The object hasn't been deleted yet.</li>
</ol>In either case you can still safely access the object after the unlock.  
(<a href="../include/deds/atom.h">../include/deds/atom.h</a>)<br>(library <a href="deds.htm">deds</a> : module <a href="deds_atom.htm">atom</a>)
<p></li>
<li>
<a name="unsigned mx_lastlock(const MX_LOCK* lock)"><code>unsigned mx_lastlock(const MX_LOCK* lock)</code></a>
<p>
<p><b>Find out if a lock is the last one of an object  </b><p>
(<a href="../include/deds/atom.h">../include/deds/atom.h</a>)<br>(library <a href="deds.htm">deds</a> : module <a href="deds_atom.htm">atom</a>)
<p></li>
<li>
<a name=" define MX_REF(type)"><code># define MX_REF(type)</code></a>
<p>
<p><b>A reference type, a typed MX_LOCK</b><p>
This macro defines a MX_LOCK where the target is of some defined type.
A reference functions the same way as a MX_LOCK except the locked (i.e. referenced)
object is available in a typesafe way.  A pointer to the reference target is
available with the MXREF macro.   
(<a href="../include/deds/atom.h">../include/deds/atom.h</a>)<br>(library <a href="deds.htm">deds</a> : module <a href="deds_atom.htm">atom</a>)
<p></li>
<li>
<a name=" define mx_ref(r,t)"><code># define mx_ref(r,t)</code></a>
<p>
<p><b>Construct a MX_REF</b><p>
The macro constructs a MX_REF to an object.  
(<a href="../include/deds/atom.h">../include/deds/atom.h</a>)<br>(library <a href="deds.htm">deds</a> : module <a href="deds_atom.htm">atom</a>)
<p></li>
<li>
<a name=" define mx_unref(r)"><code># define mx_unref(r)</code></a>
<p>
<p><b>Destruct a MX_REF</b><p>
The macro destroys a MX_REF to an object.  The object may
be deleted in the dereference, see the mx_unlock() macro.  
(<a href="../include/deds/atom.h">../include/deds/atom.h</a>)<br>(library <a href="deds.htm">deds</a> : module <a href="deds_atom.htm">atom</a>)
<p></li>
<li>
<a name=" define MXREF(r)"><code># define MXREF(r)</code></a>
<p>
<p><b>Return the object behind a MX_REF</b><p>
Return the object behind the MX_REF to an object.  
(<a href="../include/deds/atom.h">../include/deds/atom.h</a>)<br>(library <a href="deds.htm">deds</a> : module <a href="deds_atom.htm">atom</a>)
<p></li>
</ul><p>Generated by <a href="http://www.deleveld.dds.nl/mxdoc/index.htm">MXDOC</a> 2.2 on Sun Feb  4 15:16:26 2007


</body></html>
